import schimpy
from schimpy import station
dfs = station.read_station_in('../tests/data/m1_hello_schism/station.in')
dfs = dfs.reset_index()
from schimpy import schism_mesh
grid = schism_mesh.read_mesh('../tests/data/m1_hello_schism/hgrid.gr3')
import holoviews as hv
hv.extension('bokeh')
from holoviews import opts, dim
from holoviews.operation import datashader
import warnings
warnings.filterwarnings('ignore')
trimesh = hv.TriMesh((grid.elems, grid.nodes))
# rasterize to view faster, zoom in to clarify features
img = datashader.rasterize(trimesh.edgepaths).opts(opts.Image(cmap=['darkblue'])).opts(width=800, height=400)
# spread image pixels to see mesh in a more bold style
elems_only = datashader.spread(img)
nodes_only = datashader.dynspread(datashader.rasterize(trimesh.nodes).opts(opts.Image(cmap=['blue'])), shape='circle', max_px=6)
full_mesh = elems_only*nodes_only
elems_only.opts(alpha=0.2)*hv.Points(dfs, kdims=['x','y'],
vdims=['z','id','subloc','name']).opts(color='red',
size=10,
tools=['hover'])
trimesh = hv.TriMesh((grid.elems, grid.nodes))
# rasterize to view faster, zoom in to clarify features
img = datashader.rasterize(trimesh.edgepaths).opts(opts.Image(cmap=['darkblue'])).opts(width=800, height=400)
# spread image pixels to see mesh in a more bold style
elems_only = datashader.spread(img)
nodes_only = datashader.dynspread(datashader.rasterize(trimesh.nodes).opts(opts.Image(cmap=['blue'])), shape='circle', max_px=6)
full_mesh = elems_only*nodes_only
elems_only.opts(alpha=0.2)*hv.Points(dfs, kdims=['x','y'],
vdims=['z','id','subloc','name']).opts(color='red',
size=10,
tools=['hover'])
# param.nml has the time in the OPT section, but no parser for .nml files found
from datetime import datetime
import pandas as pd
import hvplot.pandas
def read_and_plot(file, station_file, reftime):
df1 = station.read_staout(file, station_file, reftime)
df1.index.name='Time' # workaround for hvplot bug
return df1.hvplot()
reftime = datetime(2000,1,1)
plots = []
for index in range(1,10):
fpath = f'../tests/data/m1_hello_schism/outputs/staout_{index}'
station_file = '../tests/data/m1_hello_schism/station.in'
vartype = schimpy.station.station_variables[index-1]
try:
plot = read_and_plot(fpath, station_file, reftime).opts(ylabel=f'{vartype}')
plots.append(plot)
except:
pass
#print(f'No data for index: {index}: {vartype}')
hv.Layout(plots).cols(1).opts(shared_axes=False)